package org.jeecg.modules.audit.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.audit.entity.ConActivityRemarkReply;
import org.jeecg.modules.audit.service.IConActivityRemarkReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

/**
* @Description: 活动评论回复
* @Author: jeecg-boot
* @Date:   2020-05-09
* @Version: V1.0
*/
@Slf4j
@Api(tags="活动评论回复")
@RestController
@RequestMapping("/activity/conActivityRemarkReply")
public class ConActivityRemarkReplyController extends JeecgController<ConActivityRemarkReply, IConActivityRemarkReplyService> {
   @Autowired
   private IConActivityRemarkReplyService conActivityRemarkReplyService;

   /**
    * 分页列表查询
    *
    * @param conActivityRemarkReply
    * @param pageNo
    * @param pageSize
    * @param req
    * @return
    */
   @AutoLog(value = "活动评论回复-分页列表查询")
   @ApiOperation(value="活动评论回复-分页列表查询", notes="活动评论回复-分页列表查询")
   @GetMapping(value = "/list")
   public Result<?> queryPageList(ConActivityRemarkReply conActivityRemarkReply,
                                  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                  HttpServletRequest req) {
       QueryWrapper<ConActivityRemarkReply> queryWrapper = QueryGenerator.initQueryWrapper(conActivityRemarkReply, req.getParameterMap());
       Page<ConActivityRemarkReply> page = new Page<ConActivityRemarkReply>(pageNo, pageSize);
       IPage<ConActivityRemarkReply> pageList = conActivityRemarkReplyService.page(page, queryWrapper);
       return Result.ok(pageList);
   }

   /**
    * 添加
    *
    * @param conActivityRemarkReply
    * @return
    */
   @AutoLog(value = "活动评论回复-添加")
   @ApiOperation(value="活动评论回复-添加", notes="活动评论回复-添加")
   @PostMapping(value = "/add")
   public Result<?> add(@RequestBody ConActivityRemarkReply conActivityRemarkReply) {
       conActivityRemarkReplyService.save(conActivityRemarkReply);
       return Result.ok("添加成功！");
   }

   /**
    * 通过id查询
    *
    * @param id
    * @return
    */
   @AutoLog(value = "活动评论回复-通过id查询")
   @ApiOperation(value="活动评论回复-通过id查询", notes="活动评论回复-通过id查询")
   @GetMapping(value = "/queryById")
   public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
       ConActivityRemarkReply conActivityRemarkReply = conActivityRemarkReplyService.getById(id);
       return Result.ok(conActivityRemarkReply);
   }

}
